package com.iss.demo.dao;

import com.iss.demo.entity.xtCourse;
import com.iss.demo.model.xtCourseModel;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface xtCourseDao {

    @Select("select * from xt_course inner join coursetype on xt_typeid=t_id")
    List<xtCourseModel> selectAll();


    @Delete(" <script>"+"delete from xt_course where xt_id in" +
            "    <foreach collection=\"array\" item=\"id\" separator=\",\" open=\"(\" close=\")\">" +
            "        #{id}" +
            "    </foreach></script>")
    public Integer delete(Integer[] xt_ids);

    @Insert("insert into xt_course values(null,#{xt_name},#{xt_typeid},#{xt_time},#{xt_price},#{xt_des},1,null,null)")
    public Integer insertCourse(xtCourse xtcourse);

    @Update("update xt_course set xt_name=#{xt_name},xt_typeid=#{xt_typeid},xt_time=#{xt_time},xt_price=#{xt_price},xt_des=#{xt_des} where xt_id=#{xt_id}")
    public Integer updateCourse(xtCourse xtcourse);

    @Select("select * from xt_course where xt_id=#{xt_id}")
    public xtCourse selectByid(Integer id);

    @Update("update xt_course set xt_surface = #{surface},xt_info = #{info} where xt_id=#{id}")
    public Integer updateInfo(@Param("surface") String surface,@Param("info") String info,@Param("id") Integer id);

    @Select("select * from xt_course inner join coursetype on xt_typeid=t_id where xt_id=#{xt_id}")
    public xtCourseModel selectInfoById(Integer xt_id);

}
